package org.springcloud.wisdom.spring_02_classroom.teacher.list;

import org.springcloud.wisdom.spring_02_classroom.teacher.tschedule.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    // 获取教师列表的接口
    @GetMapping("/list")
    public ResponseEntity<List<Teacher>> getTeacherList() {
        List<Teacher> teachers = teacherService.getAllTeachers();
        if (teachers != null && !teachers.isEmpty()) {
            return ResponseEntity.ok(teachers);
        } else {
            return ResponseEntity.notFound().build();
        }
    }
}
